<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: console.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: console.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * 打印日志模块
 * @module utils/console
 * @author 陈华春
 *
 * @example
 *  // 基础用法
 *  import {log} from '@/utils/console'
 *  log('日志内容')
 */

import * as config from '../config'

/**
 * 是否开启在生产模式时打印日志， 可以在 /src/config.js 中配置
 * @const
 */
const DE_BUG = process.env.NODE_ENV === 'production' ? !!config.DE_BUG : true

const COLORS = {
  default: '#35495E',
  primary: '#3488ff',
  success: '#43B883',
  warn: '#e6a23c',
  error: '#f56c6c'
}

/**
 * 内部调用 console 对象的方法
 * @inner
 * @param {string} name 方法名称
 * @param {Array} args 参数数组
 */
function applyMethod(name, args) {
  if (DE_BUG &amp;&amp; window.console) {
    const method = window.console[name]
    try {
      method.apply(method, args)
    } catch (e) {
    }
  }
}

/**
 * 输出提示信息
 * @param {string} title 标题
 * @param {string} info 内容
 * @param {string} [type=primary] 颜色类型，支持：primary/success/warn/error
 */
export function tip(title, info, type = 'primary') {
  log(
    `%c ${title} %c ${info} %c`,
    'background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;',
    `background:${COLORS[type]}; padding: 1px; border-radius: 0 3px 3px 0;  color: #fff;`,
    'background:transparent'
  )
}

/**
 * 打印信息日志
 * @param {...string} content 日志内容
 */
export function log(content) {
  applyMethod('log', arguments)
}

/**
 * 打印警告日志
 * @param {...string} content 日志内容
 */
export function warn(content) {
  applyMethod('warn', arguments)
}

/**
 * 打印错误日志
 * @param {...string} content 日志内容
 */
export function error(content) {
  applyMethod('error', arguments)
}

/**
 * 枚举对象属性
 * @param {...string} obj 对象
 */
export function dir(obj) {
  applyMethod('dir', arguments)
}
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-utils_ajax.html">utils/ajax</a></li><li><a href="module-utils_axios.html">utils/axios</a></li><li><a href="module-utils_bus.html">utils/bus</a></li><li><a href="module-utils_console.html">utils/console</a></li><li><a href="module-utils_convert.html">utils/convert</a></li><li><a href="module-utils_cookie.html">utils/cookie</a></li><li><a href="module-utils_crypto.html">utils/crypto</a></li><li><a href="module-utils_date.html">utils/date</a></li><li><a href="module-utils_directives_clipboard.html">utils/directives/clipboard</a></li><li><a href="module-utils_directives_draggable.html">utils/directives/draggable</a></li><li><a href="module-utils_directives_droppable.html">utils/directives/droppable</a></li><li><a href="module-utils_directives_resizable.html">utils/directives/resizable</a></li><li><a href="module-utils_directives_selecttext.html">utils/directives/selecttext</a></li><li><a href="module-utils_dom.html">utils/dom</a></li><li><a href="module-utils_download.html">utils/download</a></li><li><a href="module-utils_events.html">utils/events</a></li><li><a href="module-utils_lunar.html">utils/lunar</a></li><li><a href="module-utils_mock.html">utils/mock</a></li><li><a href="module-utils_openlayer.html">utils/openlayer</a></li><li><a href="module-utils_queue.html">utils/queue</a></li><li><a href="module-utils_skin.html">utils/skin</a></li><li><a href="module-utils_storage.html">utils/storage</a></li><li><a href="module-utils_theme.html">utils/theme</a></li><li><a href="module-utils_tween.html">utils/tween</a></li><li><a href="module-utils_url.html">utils/url</a></li><li><a href="module-utils_util.html">utils/util</a></li></ul><h3>Classes</h3><ul><li><a href="module-utils_directives_draggable-Draggable.html">Draggable</a></li><li><a href="module-utils_directives_droppable-Droppable.html">Droppable</a></li><li><a href="module-utils_directives_resizable-Resizable.html">Resizable</a></li><li><a href="module-utils_events-Events.html">Events</a></li><li><a href="module-utils_openlayer-Openlayers.html">Openlayers</a></li><li><a href="module-utils_queue-Queue.html">Queue</a></li></ul><h3>Events</h3><ul><li><a href="module-utils_queue-Queue.html#event:complete">complete</a></li><li><a href="module-utils_queue-Queue.html#event:error">error</a></li><li><a href="module-utils_queue-Queue.html#event:success">success</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 28 2018 10:45:22 GMT+0800 (CST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
